<?php

namespace App\Http\Controllers\Api\V1\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Carbon\Carbon;

class ActivityRecordResource extends JsonResource
{
    public function toArray($request)
    {
        $resource = $this->resource;
    
        $status = "";
        if($resource->is_qd ==1){

            $status="已签到";
        }else{
            if(Carbon::now()->gt($resource->end_at)){

                $status="已过期";
            }else{

                $status="未签到";
            }
        }
        return [
            'id'                => (int)$resource->id,
            'money'                => $resource->money,
            'status'             =>  $status,
            'activity'             => new ActivityResource($this->activity),
            'created_at'          =>(string)$resource->created_at,
            
        ];
    }
}
